package com.huffman.smart_picture.domain.request.picture;

import cn.hutool.json.JSONUtil;
import com.huffman.smart_picture.domain.entity.Picture;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PictureUpdateRequest implements Serializable {
  
    /**  
     * id  
     */  
    private Long id;

    /**
     * 空间 id
     */
    @ApiModelProperty(value = "空间id 不传默认为公共图库")
    private Long spaceId;

    /**  
     * 图片名称  
     */  
    private String name;  
  
    /**  
     * 简介  
     */  
    private String introduction;  
  
    /**  
     * 分类  
     */  
    private String category;  
  
    /**  
     * 标签  
     */  
    private List<String> tags;
  
    private static final long serialVersionUID = 1L;

    public static Picture convert(PictureUpdateRequest pictureUpdateRequest){
        Picture picture = new Picture();
        picture.setId(pictureUpdateRequest.getId());
        picture.setSpaceId(pictureUpdateRequest.getSpaceId());
        picture.setPicName(pictureUpdateRequest.getName());
        picture.setIntroduction(pictureUpdateRequest.getIntroduction());
        picture.setCategory(pictureUpdateRequest.getCategory());
        picture.setTags(JSONUtil.toJsonStr(pictureUpdateRequest.getTags()));

        return picture;
    }
}
